<template>
  <el-radio-group v-model="checkRadio">
    <el-radio v-for="item in publishTypes" :key="item.name" :value="item.name">
      {{ item.label }}
    </el-radio>
  </el-radio-group>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import { publishTypeDict, PublishType } from '@/utils/api/announcement/type';
import { enumToList } from '@/utils/enum';
const checkRadio = ref<PublishType>(PublishType.Immediately);
const publishTypes = ref<Array<{ label: string; name: PublishType }>>([]);
onMounted(async () => {
  const publishTypeEnums = enumToList(PublishType);
  const publishTypeArrays = new Array<{ label: string; name: PublishType }>();
  for (let item of publishTypeEnums) {
    const publishType: PublishType = item.value as PublishType;
    publishTypeArrays.push({
      name: publishType,
      label: publishTypeDict.get(publishType)!
    });
  }
  publishTypes.value = publishTypeArrays;
});
</script>
